function myswf(opts){
	//当需要进度条时序引人fileprogress.js
	if(opts.progresslist)
		opts.progress=true;
	else 
		opts.progress=false;
	if(!opts.button_image_url)opts.button_image_url="common/images/icon/picupload.jpg";
	if(!opts.queue_limit){opts.queue_limit=1};
	var rootpath=opts.basepath;
	function fileQueued(file) {
		if(!opts.progress)return ;
		try {
			var progress = new FileProgress(file, this.customSettings.progressTarget);
			progress.setStatus("正在上传请稍后...");
			progress.toggleCancel(true, this);
		} catch (ex) {
			this.debug(ex);
		}
	}
	function fileQueueError(file, errorCode, message) {
		try {
			if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
				alert("队列文件数量超过设定值.");
				return;
			}
			if(opts.progress)
			{
				var progress = new FileProgress(file, this.customSettings.progressTarget);
				progress.setError();
				progress.toggleCancel(false);
			}
			switch (errorCode) {
			case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
				progress.setStatus("队列文件数量超过设定值.");
				break;
			case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
				progress.setStatus("请不要上传空文件.");
				break;
			case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
				progress.setStatus("文件类型不合法.");
				break;
			default:
				if (file !== null) {
					progress.setStatus("上传失败！");
				}
				break;
			}
		} catch (ex) {
	        this.debug(ex);
	    }
	}
	function uploadProgress(file, bytesLoaded, bytesTotal) {
		if(!opts.progress)return ;
		try {
			var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);
			var progress = new FileProgress(file, this.customSettings.progressTarget);
			progress.setProgress(percent);
			progress.setStatus("已上传 " + percent+ "% ......");
		} catch (ex) {
			this.debug(ex);
		}
	}
	function fileDialogComplete(numFilesSelected, numFilesQueued) {
        this.startUpload();
	}
	function uploadError(file, errorCode, message) {
		if(opts.progress)
		{
			var progress = new FileProgress(file, this.customSettings.progressTarget);
			progress.setComplete();
			progress.setStatus("上传失败.");	
			progress.toggleCancel(true);
		}
		alert("上传失败.");
	}
	function uploadSuccess(file, serverData) {
		var data = eval("(" +serverData + ")");
		if(opts.progress)
		{
			var progress = new FileProgress(file, this.customSettings.progressTarget);
			progress.setComplete();
			progress.setStatus("上传成功.");	
			progress.toggleCancel(true);
		}
		if(data.success){
			opts.success(data);
		}else{
			alert("上传失败.");
		}
		this.startUpload();
	}
	
	function getprogressTarget()
	{
		return { progressTarget : "filesList"};
	}
	
	
			var settings = {
					flash_url : rootpath+"/common/js/swfupload/swfupload.swf",
					upload_url: rootpath+"/uploadAction!upload"+opts.type+".action",
					file_size_limit : 30+"MB",
					file_types : "*.jpg;*.png;*.jpeg;*.bmp;*.gif;",
					file_types_description : "只允许上传图片",
					file_queue_limit:opts.queue_limit,
					
					// Button settings
					button_image_url: rootpath+"/"+opts.button_image_url,
					button_width: "91",
					button_height: "27",
					button_placeholder_id: opts.buttonholder,
					button_text_left_padding: 0,
					button_text_top_padding: 0,
					
					custom_settings : { progressTarget : opts.progresslist},
	
					//The event handler functions are defined in handlers.js
					file_queued_handler : fileQueued,
					file_queue_error_handler : fileQueueError,
					file_dialog_complete_handler : fileDialogComplete,
					upload_progress_handler : uploadProgress,
					upload_error_handler : uploadError,
					upload_success_handler : uploadSuccess
					
					};
					//自定义属性，是否停止上传
			swfUpload = new SWFUpload(settings);
		
	
} 